package com.bangyu.monitor.core.util;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Auther: zhangxue
 * @Date: 19/4/17 14:24
 * @Description: 挠度计算
 */
public class BendCacuUtil {

    private static final BigDecimal displaymentChangeConstatnt = new BigDecimal(-0.0123);//静态挠度随温度变化常量值

    /**
     * 通过荷载值计算挠度值
     * y=ax3+bx2+cx+d
      * @param load
     * @return
     */
    public static Float bendCacu(Float load){
//        return new Double(Math.random()*1.2).floatValue();
        return load;
    }

    /**
     * 已知某温度下的静态位移，获取目标温度下的静态位移
     * 变化量公式：△X=-0.0123*△T
     * @param currentTemperature
     * @param currentDisplayment
     * @param targetTemperature
     * @return
     */
    public static Float cacuTargetDisplaymentFromCurrent(Float currentTemperature,Float currentDisplayment,Float targetTemperature){
        if(currentTemperature != null && currentDisplayment != null && targetTemperature != null){
            BigDecimal ct = new BigDecimal(currentTemperature);
            BigDecimal cb = new BigDecimal(currentDisplayment);
            BigDecimal tt = new BigDecimal(targetTemperature);
            return cb.add(displaymentChangeConstatnt.multiply(tt.subtract(ct))).floatValue();
        }
        return null;
    }

    public static void main(String[] args) {
//        for(int i =0;i<20;i++){
//            System.out.println(bendCacu(1f));
//        }
        Date now = new Date();
        System.out.println(now.getTime());
        System.out.println((now.getTime()/1000)*1000);
        System.out.println(BendCacuUtil.class.getResource("/").getPath());

    }
}
